import fetch from 'common/src/utils/fetch';
import baseUrl from './env';
// 获取前20条期刊数据
function getJournalInfoList(param) {
    let data = {
        condition: {
            enabled: 1,
            journalNameOrNumber: '',
            journalType: param.journalType,
            searchType: param.searchType
        },
        pageNum_: 1,
        pageSize_: 20
    };
    return fetch({
        url: `${baseUrl}/journalInformation/getJournalInformationList`,
        method: 'post',
        data
    });
}

function addJournalInfo(data) {
    return fetch({
        url: `${baseUrl}/journalInformation/addJournalInformation`,
        method: 'post',
        data
    });
}

// 下载模板
function downloadTemplate(data = {}) {
    // return fetch({
    //     url: `${baseUrl}/journalInformation/downloadTemplate`,
    //     method: 'get'
    // });
    let url = `${baseUrl}/journalInformation/downloadTemplate`;
    window.open(url);
}

function updateJournalInfo(data) {
    return fetch({
        url: `${baseUrl}/journalInformation/updateJournalInformation`,
        method: 'post',
        data
    });
}

function deleteJournalInfo(data) {
    return fetch({
        url: `${baseUrl}/journalInformation/deleteJournalInformation`,
        method: 'post',
        data
    });
}

function getJournalItemInfoById(data) {
    return fetch({
        url: `${baseUrl}/journalInformation/getJournalInformation`,
        method: 'get',
        params: data
    });
}

export default {
    'getJournalInfoList': getJournalInfoList, // 获取前20条期刊信息
    'addJournalInfo': addJournalInfo, // 新增期刊信息
    'deleteJournalInfo': deleteJournalInfo, // 删除期刊信息
    'getJournalItemInfoById': getJournalItemInfoById, // 编辑期刊信息
    'updateJournalInfo': updateJournalInfo, // 获取单条期刊信息
    downloadTemplate
};

